package org.example.guide.controller;

import org.example.guide.domain.RealtimeInfo;
import org.example.guide.service.realtimeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/")

public class realtimeInfoController {
    @Autowired
    realtimeInfoService realtimeinfoService;
    @GetMapping("/realtimeInfo")
    public List<RealtimeInfo> showrealtimeInfo(){
        return realtimeinfoService.showrealtimeInfo();
    }

    @GetMapping ("/searchrealtimeInfo")
    public List<RealtimeInfo> searchrealtimeInfo(String keyword){
        System.out.println(keyword);
        return realtimeinfoService.searchrealtimeInfo(keyword);
    }

    @GetMapping ("/searchrealtimeInfoByGuideID")
    public RealtimeInfo searchrealtimeInfoByGuideID(int guideID){
        return realtimeinfoService.searchrealtimeInfoByID(guideID);
    }

    @PostMapping("/insertrealtimeInfo")
    public void insertrealtimeInfo(@RequestBody RealtimeInfo realtimeInfo){
        realtimeinfoService.insertRealtimeInfo(realtimeInfo);
    }

    @GetMapping("/deleterealtimeInfo")
    public void deleterealtimeInfo(int id){
        realtimeinfoService.deleteRealtimeInfo(id);
    }
}
